﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DoAnB
{
    public partial class frmCapNhatCaNhan : Form
    {
        public frmCapNhatCaNhan()
        {
            InitializeComponent();
            ketnoi kn = new ketnoi();
            string sql = "Select * from NguoiDung where MaNV = "+ Session._MaNV ;
            DataTable dt = kn.getDataTable(sql);
            txtHoTen.Text = dt.Rows[0]["TenNV"].ToString();
            txtDiaChi.Text = dt.Rows[0]["DiaChi"].ToString();
            txtCMND.Text = dt.Rows[0]["CMND"].ToString();
            txtSDT.Text = dt.Rows[0]["SoDienThoai"].ToString();
            dateTimePicker1.Value = (DateTime)dt.Rows[0]["NgaySinh"];
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string sql = "Update NguoiDung Set TenNV=N'" + txtHoTen.Text + "', DiaChi=N'" + txtDiaChi.Text + "', CMND=N'" + txtCMND.Text + "', SoDienThoai=N'" + txtSDT.Text + "',NgaySinh='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "' Where MaNV = " + Session._MaNV;
            ketnoi kn = new ketnoi();
            kn.ExeCuteNonQuery(sql);
            MessageBox.Show("Cập nhật thành công!","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information);
            DialogResult = DialogResult.OK;

        }
    }
}
